package com.woniuxy.mapper.impl;

import java.sql.*;

/**
 * @author 作者
 * @create 2025-06-16 16:48
 */
public class JdbcUtil {

    public static Connection getConnection() throws Exception {
        String className = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql:///db1";
        String user = "root";
        String password = "123";
        Class.forName(className);
        return DriverManager.getConnection(url, user, password);
    }

    public static void close(Connection connection, Statement statement, ResultSet resultSet) throws SQLException {
        if (resultSet != null) {
            resultSet.close();
        }
        if (statement != null) {
            statement.close();
        }
        if (connection != null) {
            connection.close();
        }
    }



}
